package com.baidu.fenfayun.demo.util

import com.qmuiteam.qmui.widget.dialog.QMUITipDialog
import  android.content.*
object DialogUtil{
   enum class Stype{
      FAIL, SUCCESS ,LOADING,INFO
   }


   @JvmStatic fun show( ctx:Context,tips:String,type:Stype ):QMUITipDialog {


      val dialogtype = when(type){

         Stype.SUCCESS ->  QMUITipDialog.Builder.ICON_TYPE_SUCCESS
         Stype.FAIL -> QMUITipDialog.Builder.ICON_TYPE_FAIL
         Stype.INFO -> QMUITipDialog.Builder.ICON_TYPE_INFO
         Stype.LOADING -> QMUITipDialog.Builder.ICON_TYPE_LOADING
      }
      val tipDialog = QMUITipDialog.Builder(ctx)
      .setIconType(dialogtype)
      .setTipWord(tips)
      .create()
      tipDialog.show()
      val hand = android.os.Handler()
      if(type != Stype.LOADING) 
      hand.postDelayed(Runnable {
         tipDialog.dismiss();
      }, 1500)
      return tipDialog
   }
}
